<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" 
    placeholder="请输入任务名称" 
    autofocus 
    @keyup.enter="add"
    v-model="inName"
    />
  </header>
</template>

<script>
export default {
  name: 'TodoListHeader',
  components: {},
  props: {

  },
  data() {
    return {
      inName: ''
    }
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    //添加
    add(){
      if(!this.inName) return alert('内容不能为空')
      this.$emit('add',this.inName)
      this.inName=''
    }
  },
}
</script>

<style scoped></style>
